home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Utilities / Random / Commodore 64c / SOURCE / Register.c < prev    next >
Text File  |  1994-03-19  |  2KB  |  85 lines

  1. /*
  2.     Commodore 64 Emulator v0.2      Earle F. Philhower III 
  3.     Copyright (C) 1993-4            (st916w9r@dunx1.ocs.drexel.edu)
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #include "ProcessorTypes.h"
  21. #include "Memory.h"
  22. #include "Vectors.h"
  23. #include "FileTypes.h"
  24.  
  25. word pc;
  26. byte a, x, y, flags, sp;
  27.  
  28. void RegisterInitialize()
  29. {
  30.     RAM[0]=RAM[1]=47;
  31.     SetUpMemoryMap();
  32.     pc=WordAt(ResetTo);
  33.     sp=255;
  34.     flags=4;
  35. }
  36.  
  37. void SaveRAMFS(FSSpec *spec)
  38. {
  39.     short fnum;
  40.     long len;
  41.     
  42.     FSpCreate(spec, (OSType)APPLTYPE, (OSType)RAMFTYPE, 0);
  43.     FSpOpenDF(spec, fsRdWrPerm, &fnum);
  44.     len=sizeof(word); FSWrite(fnum, &len, &pc);
  45.     len=sizeof(byte); FSWrite(fnum, &len, &a);
  46.     len=sizeof(byte); FSWrite(fnum, &len, &x);
  47.     len=sizeof(byte); FSWrite(fnum, &len, &y);
  48.     len=sizeof(byte); FSWrite(fnum, &len, &flags);
  49.     len=sizeof(byte); FSWrite(fnum, &len, &sp);
  50.     len=65536; FSWrite(fnum, &len, RAM);
  51.     FSClose(fnum);
  52. }
  53.  
  54. void LoadRAMFS(FSSpec *spec)
  55. {
  56.     short fnum;
  57.     long len;
  58.     
  59.     FSpOpenDF(spec, fsRdPerm, &fnum);
  60.     len=sizeof(word); FSRead(fnum, &len, &pc);
  61.     len=sizeof(byte); FSRead(fnum, &len, &a);
  62.     len=sizeof(byte); FSRead(fnum, &len, &x);
  63.     len=sizeof(byte); FSRead(fnum, &len, &y);
  64.     len=sizeof(byte); FSRead(fnum, &len, &flags);
  65.     len=sizeof(byte); FSRead(fnum, &len, &sp);
  66.     len=65536; FSRead(fnum, &len, RAM);
  67.     FSClose(fnum);
  68. }
  69.  
  70. void SaveRAM(void)
  71. {
  72.     StandardFileReply reply;
  73.     
  74.     StandardPutFile("\pSave RAM Image:", "\pRAM", &reply);
  75.     if (reply.sfGood) SaveRAMFS(&(reply.sfFile));
  76. }
  77.  
  78. void LoadRAM(void)
  79. {
  80.     StandardFileReply reply;
  81.     
  82.     StandardGetFile(nil, (short)-1, nil, &reply);
  83.     if (reply.sfGood) LoadRAMFS(&(reply.sfFile));
  84. }
  85.